<div style="position: absolute;top: 120px; left: 450px">
    <font style="font-size: 25px ;color: #e8198b">库存盘点：</font>&nbsp;&nbsp;</div>
<table class="altrowstable">
    <tr>
        <td>编号</td>
        <td>产品编号</td>
        <td>产品名称</td>
        <td>库存数量</td>
        <td>采购在途数</td>
        <td>预销售数</td>
        <td>盘点</td>
        <td>盘点记录</td>
    </tr>
    <tbody id="stockBody">

    </tbody>
    <div  style="position: absolute; margin-top: 0px;padding-left: 700px">
        <ul id="page">分页</ul>
    </div>
</table>


<script type="text/html" id="stockTemplate">
    {{each data}}
    <tr>
        <td>{{$index+1}}</td>
        <td>{{$value.productCode}}</td>
        <td>{{$value.name}}</td>
        <td>{{$value.num}}</td>
        <td>{{$value.poNum}}</td>
        <td>{{$value.soNum}}</td>
        <td><font style="color: #e8198b" onclick="{{'checkStock(\''+ $value.productCode +'\')'}}">盘点</font></td>
        <td><font style="color: #e8198b" onclick="{{'getCheckStock(\''+ $value.productCode +'\')'}}">盘点记录</font></td>

    </tr>
    {{/each}}
</script>
<script>


    function getCheckStock(productCode) {

     Ajax.getHtml('showCheckStock.html',function (html) {
         Ajax.post('getCheckStock',{
             productCode:productCode},
             function (result) {
             var str =template("stock",result);
             document.getElementById("stocks").innerHTML=str
         });
         layer.open({
             type:1,
             title:'盘点记录查看',
             area: ['800px',['400px']],
             content: html,
             btn: ['确认', '取消'],
             yes:function () {
                 layer.closeAll();
             }
         })
     })
    }



    function checkStock(productCode){
    Ajax.getHtml('checkNum.html',function (html) {
        Ajax.post('getOneProduct',{
            productCode:productCode
        },function (result) {
            $('#proName').val(result.data.name);
            $('#proCode').val(result.data.productCode)
        })
        layer.open({
            title:'盘点记录',
            area: ['800px',['400px']],
            content: html,
            btn: ['确认', '取消'],
            yes:function () {
                Ajax.post('addCheckStock',{
                    productCode:$('#proCode').val(),
                    num:$('#num').val(),
                    type:$('#type').find("option:selected").val(),
                    description:$('#description').val()
                },function (result) {
                    alert(result.message);
                    show('checkStock.html')
                })
                layer.closeAll();
            }
        })
    })

    }

    $(function () {
        showPage({
            currentPage: 1,
            pageSize: 3,
            url:'/productList',
            templateId:"stockTemplate",
            contentId:"stockBody"
        })
    })
</script>